/**
 * 
 */
package org.lora.smp.document;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.lora.biz.ou.LoraOUConstant;
import org.lora.core.annotation.Action;
import org.lora.mvc.annotation.RequestPath;
import org.lora.mvc.annotation.ResponseJSON;
import org.lora.mvc.entity.ViewData;
import org.lora.smp.SmpConstant;
import org.lora.smp.common.CommconSmpAction;
import org.lora.util.ValidateUtil;
import org.lora.webframework.common.CommonConstant;
import org.lora.webframework.common.JsonResult;

/**
 * <p>
 * 类名:DocumentSmpAction
 * </p>
 * 描述:<br>
 * 创建时间:2016年10月24日 下午4:25:42<br>
 * 
 * @author Bladnir@outlook.com<br>
 *         修改历史:<br>
 *         2016年10月24日 Bladnir 创建<br>
 */

@Action
@RequestPath(path = "/smp/document")
public class DocumentSmpAction extends CommconSmpAction {

	/**
	 * 打开文档页面
	 * 
	 * @param request
	 * @return
	 */
	@RequestPath(path = "/showDocument")
	public ViewData showDocument(HttpServletRequest request) {

		String processDefinitionId = request.getParameter("processDefinitionId");
		String processDefinitionNumber = request.getParameter("processDefinitionNumber");
		String documentType = request.getParameter("documentType");
		String version = request.getParameter("version");
		String domainId = request.getParameter("domainId");

		String processInstanceId = request.getParameter("processInstanceId");
		String taskId = request.getParameter("taskId");

		Map<String, Object> dataMap = new HashMap<>();
		dataMap.put("processDefinitionId", processDefinitionId);
		dataMap.put("processDefinitionNumber", processDefinitionNumber);
		dataMap.put("documentType", documentType);
		dataMap.put("taskId", taskId);
		dataMap.put("processInstanceId", processInstanceId);
		dataMap.put("version", version);
		dataMap.put("domainId", domainId);

		String documentJsp = "";
		if (ValidateUtil.isEqual(documentType, SmpConstant.DOC_DRAFT) || ValidateUtil.isEqual(documentType, SmpConstant.DOC_TODO)) {
			documentJsp = "/jsp/smp/shortMessageSendApprove.jsp";
		} else if (ValidateUtil.isEqual(documentType, SmpConstant.DOC_HAVEDO)) {
			documentJsp = "/jsp/smp/shortMessageSendApproveRead.jsp";
		}

		return new ViewData(documentJsp, dataMap);
	}

	/**
	 * 打开待办列表
	 * 
	 * @return
	 */
	@RequestPath(path = "/showTodoList")
	public ViewData showTodoList() {
		return new ViewData("/jsp/smp/view/todoList.jsp");
	}

	/**
	 * 打开已办列表
	 * 
	 * @return
	 */
	@RequestPath(path = "/showHavedoList")
	public ViewData showHavedoList() {
		return new ViewData("/jsp/smp/view/havedoList.jsp");
	}
	
	@RequestPath(path = "/getProcessTrackData")
	@ResponseJSON
	public JsonResult getProcessTrackData(HttpServletRequest request) {
		JsonResult result = new JsonResult();

		result.setFlag(CommonConstant.FAIL);
		
		String processInstanceId = request.getParameter("processInstanceId");
		
		return result;
	}

}
